<h1><?php __d('lil_media', 'View File'); ?></h1>
<div class="index">
<?php
	$path_parts = pathinfo($base_path . DS . $filename);
	
	echo '<div class="view_media_item">';
	
	$icon = '';
	if (in_array($path_parts['extension'], array('gif', 'png', 'jpg'))) {
		$icon = $this->Html->image($www_dir . $path_parts['basename']);
	} else if (in_array($path_parts['extension'], array('doc', 'docx'))) {
		$icon = $this->Html->image('doc.gif');
	} else if (in_array($path_parts['extension'], array('xls', 'xlsx'))) {
		$icon = $this->Html->image('xls.gif');
	} else if ($path_parts['extension'] == 'pdf') {
		$icon = $this->Html->image('pfd.gif');
	} else {
		$icon = $this->Html->image('x.gif');
	}
	
	echo $this->Html->link(
		$icon,
		array(
			'action'   => 'download',
			'path'     => (!empty($this->params['named']['path'])) ?
				$this->params['named']['path'] : null,
			'filename' => $path_parts['basename']
		),
		array('escape' => false)
	);
	
	echo '<div class="media_name">';
	echo $this->Html->link(
		$path_parts['basename'],
		array(
			'admin'  => false,
			'action' => 'download',
			'path'   => (!empty($this->params['named']['path'])) ?
				$this->params['named']['path'] : null,
			'filename'   => $path_parts['basename']
		)
	);
	echo '</div>';
	echo '</div>';
?>
</div>